import React from 'react'

// 此处为接口返回值的类型声明，该定义在接口返回处
export interface Users {
	id: number
	name: string
	token: string
}

interface SearchPannelProps {
	params: {
		name: string
		personId: string
	}
	setParams: (params: SearchPannelProps['params']) => void
	users: Users[]
}

export const SearchPannel = ({
	params,
	setParams,
	users
}: SearchPannelProps) => {
	return (
		<form>
			<div>
				<input
					type="text"
					value={params.name}
					onChange={(evt) =>
						setParams({
							...params,
							name: evt.target.value
						})
					}
				/>
				<select
					value={params.personId}
					onChange={(evt) =>
						setParams({
							...params,
							personId: evt.target.value
						})
					}
				>
					<option value="">负责人</option>
					{users.map((user) => (
						<option value={user.id} key={user.id}>
							{user.name}
						</option>
					))}
				</select>
			</div>
		</form>
	)
}
